const express = require("express");
const cors = require("cors");
const config = require("./config/index");
const router = require("./router");
const errorHandler = require("./middleware/error");
const app = express();

//开发阶段允许跨域
app.use(cors());
app.use(express.urlencoded({ extended: true }));
app.use(express.json());

app.use("/v1", router);

// 全局错误中间件
app.use(errorHandler());

app.listen(config.webport, () => {
  console.log(`this server runnig at http://localhost:${config.webport}`);
});
